﻿@model ESupervision.Models.Message

@{
    ViewBag.Title = "Messaging - Compose";

}
<link href="@Url.Content("~/Content/chosen.min.css")" rel="stylesheet" />
<h2>Compose Message</h2>

<div class="row">
    <div class="col-md-2">
        <p>
            <button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("Compose")'">Compose</button>

        </p>
        <ul class="nav nav-pills nav-stacked">
            <li role="presentation" class="active"><a href="@Url.Action("Index")">Inbox</a></li>
            <li role="presentation"><a href="@Url.Action("Sent")">Sent</a></li>
        </ul>

    </div>
    <div class="col-md-10">
        @using (Html.BeginForm("Compose"))
        {
            @Html.AntiForgeryToken()

            <div class="form-horizontal">
                <h4>Compose Message</h4>
                <hr />
                @Html.ValidationSummary(true)

                <div class="form-group">
                    <label class="control-label col-md-2">To</label>
                    <div class="col-md-10">
                        @Html.ListBox("selectedUsers", ViewBag.ToUsersSelectList as MultiSelectList, new { @class = "recipient-select", data_placeholder = "Choose Recipients...", })
                        @*<table>
                                    <tr>
                                        @{
                                            int cnt = 0;
                                            List<ESupervision.Models.ApplicationUser> users = ViewBag.ToUsers;

                                            foreach (var user in users)
                                            {
                                                if (cnt++ % 3 == 0)
                                                {
                                                    @:</tr><tr>
                                        }
                                        @:<td>
                                            <input type="checkbox"
                                                   name="selectedUsers"
                                                   value="@user.Id"
                                                   checked="checked" />
                                            @user.FullName
                                        @:</td>
                                    }
                                    @:</tr>
                                }
                            </table>*@

                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Subject, new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.Subject, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.Subject)
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.Body, new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.TextAreaFor(model => model.Body, new { @class = "form-control", rows = 7 })
                        @Html.ValidationMessageFor(model => model.Body)
                        @Html.HiddenFor(model => model.SentByUserId)
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Send" class="btn btn-default" />
                    </div>
                </div>
            </div>
        }

    </div>

</div>



<div>
    @Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    <script src="@Url.Content("~/Scripts/chosen.jquery.min.js")" type="text/javascript"></script>
    <script>jQuery(".recipient-select").chosen({ width: '280px' }); </script>
}
